package edu.tcc.iot.domain;

import java.util.Date;

public class Product {
	
	public long id;
	private ProductInfo productInfo;
	private boolean warningSent;
	
	public Product(long id, ProductInfo productInfo) {
		this.id = id;
		this.productInfo = productInfo;
	}
	
	public long getId(){
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public ProductInfo getProductInfo() {
		return productInfo;
	}

	public void setProductInfo(ProductInfo productInfo) {
		this.productInfo = productInfo;
	}

	public boolean equals(Object obj) {
		Product other = (Product) obj;
		return (obj != null) && this.getProductInfo().getQuantity() == other.getProductInfo().getQuantity() && this.getProductInfo().getValidate() == other.getProductInfo().getValidate();
		
	}
	
	public String toString() {
		return 	  "[id: " + this.id 
				+ "] [name: " + this.productInfo.getName() 
				+ "] [quantity: "+ this.productInfo.getQuantity()
				+ "] [validate: " + this.productInfo.getValidate()
				+ "] ";
	}

	public boolean hasWarningSent() {
		return warningSent;
	}

	public boolean isLevelLow() {
		return productInfo.getQuantity() < 10;
	}

	public boolean isValidate() {
		return productInfo.getValidate().before(new Date());
	}
	
}
